package ThreadDemo;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

public class ThreadDemo2 {
    private static void server(){
        long a=System.currentTimeMillis();
        long i=10000000000l;
        int x=0;
        for (long j = 0; j < i; j++) {
            x++;
        }
        int y=0;
        for (long j = 0; j < i; j++) {
            y++;
        }
        long b=System.currentTimeMillis()-a;
        System.out.println("time:"+b+"ms");
    }
    private static void concurrency()  {
        long a=System.currentTimeMillis();
        long i=10000000000l;
        Thread t1=new Thread(){
            @Override
            public void run() {
                int x=0;
                for (long j = 0; j < i; j++) {
                    x++;
                }
            }
        };
        Thread t2=new Thread(){
            @Override
            public void run() {
                long y=0;
                for (long j = 0; j < i; j++) {
                    y++;
                }
            }
        };
        t1.start();
        t2.start();
        try {
            t1.join();
            t2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long b=System.currentTimeMillis();
        long c=b-a;

        System.out.println("time :"+c+"ms");
    }
    public static void main(String[] args) {
        //server();
        concurrency();
    }
}
